// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'

Shader "post/transDoor2"
{
    Properties
    {
        _morez2Disapper ("morez2Disapper", Float) = -34.4
        _MainTex ("NoiseTex", 2D) = "black" {}
      
    }

    SubShader{
         Tags { "Queue" = "AlphaTest"  }
         //Tags { "Queue" = "Geo" "RenderType"="Opaque" }

        // Tags { "RenderType"="Opaque" 
        //        "LightMode"="ForwardBase"}
        // LOD 100

        Pass
        {

            CGPROGRAM
            #include "UnityCG.cginc"

            #pragma vertex vert
            #pragma fragment frag

            struct v2f { 
			    float4 pos : SV_POSITION;
                float4 uv :TEXCOORD0;
                float4 worldPos :TEXCOORD1;
                float3 normalDir :TEXCOORD2; 
            };

            float _morez2Disapper;
            sampler2D _MainTex;

            v2f vert (appdata_full v) 
            {
                v2f o;
                float4 worldPos = mul(unity_ObjectToWorld, v.vertex).xyzw /1.0; 
                o.worldPos = worldPos;
                o.uv = v.texcoord;
			    o.pos = UnityObjectToClipPos(v.vertex);
                o.normalDir = UnityObjectToWorldNormal(v.normal);

                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                clip(-i.worldPos.z + _morez2Disapper);//小于0不显示

                 // 灯光方向
                //float lightDirection = normalize(UnityWorldSpaceLightDir(i.worldPos));
                fixed3 worldLightDir = normalize(_WorldSpaceLightPos0.xyz);//获取 指向光源的方向
                float3 normalDirection = normalize(i.normalDir);
                float NdotL = saturate(dot(normalDirection,worldLightDir));
            
                //return fixed4(1,1,1,1);
                //return  NdotL * fixed4(1,1,1,1);//
                return NdotL * tex2D(_MainTex, i.uv);
            }
            ENDCG
        }
    }
    Fallback "Diffuse"
    //Fallback off
}
